//
// Created by Key-Box-Min on 24/06/2020.
//

#include "AtomicLock.h"

//
//AtomicLock lock;
//
//auto f = [](std::string s){
//    std::cout<<std::this_thread::get_id()<<"      "<<s<<std::endl;
//    std::this_thread::sleep_for(std::chrono::seconds(1));
//};
//
//auto tf1 = [](std::function<void()> f1){
//    std::thread t(f1);
//    t.join();
//};
//auto tf = [](std::function<void()> f1,std::function<void()> f2){
//    std::thread t(f1);
//    std::thread t1(f2);
//    t.join();
//    t1.join();
//};
//
////    std::cout<<"写写互斥"<<std::endl;
////    tf([&](){
////        lock.lock();            f("lock");
////        },[&](){
////        lock.lock();            f("lock");
////    });
//
////    std::cout<<"读写互斥"<<std::endl;
////    tf([&](){
////        lock.readLock();        f("r lock");
////    },[&](){
////        lock.lock();            f("lock");
////    });
//
////    std::cout<<"读读可通"<<std::endl;
////    tf([&](){
////        lock.readLock();        f("r lock");
////    },[&](){
////        lock.readLock();        f("r lock");
////    });
//
////    std::cout<<"单读通写  //要求读写在同线程"<<std::endl;
////    tf1([&](){
////        lock.readLock();        f("r lock");
////        lock.lock();            f("lock");
////    });
//
////    std::cout<<"多读斥写"<<std::endl;
////    tf([&](){
////        lock.readLock();        f("r lock");
////        lock.lock();            f("lock");
////    },[&](){
////        lock.readLock();        f("r lock");
////    });
